#pragma once

#include "Game/Scene/Entity.h"
#include "Render/Buffer/VertexBuffer.h"
#include "Render/Buffer/IndexBuffer.h"


struct VertexGpu
{
	glm::vec3 position;
	glm::vec3 normal;
	glm::vec3 tangent;
	glm::vec3 bitangent;
	glm::vec2 uv;
};

struct MaterialGpu {
	glm::vec3 emissive;
	glm::vec3 baseColor;
	float subsurface;
	float metallic;
	float specular;
	float specularTint;
	float roughness;
	float anisotropic;
	float sheen;
	float sheenTint;
	float clearcoat;
	float clearcoatGloss;
	float IOR;
	float transmission;

	MaterialGpu()
	{
		emissive = glm::vec3(0.f);
		baseColor = glm::vec3(1.f);
		subsurface = 0.0;
		metallic = 0.0;
		specular = 0.0;
		specularTint = 0.0;
		roughness = 0.0;
		anisotropic = 0.0;
		sheen = 0.0;
		sheenTint = 0.0;
		clearcoat = 0.0;
		clearcoatGloss = 0.0;
		IOR = 1.0;
		transmission = 0.0;
	}
};

struct ObjDescGpu
{
	uint64 vertexAddress;
	uint64 indexAddress;
	uint64 materialAddress;
};


class LocalEntity : public Entity
{
public:

	LocalEntity(entt::entity handle, GameScene* gameScene) : Entity(handle, gameScene) {};

	void SetColor(glm::vec4 color);

protected:

	virtual void ReleaseResource() override;

	virtual void OnTick(float deltaTime) override;

public:

	MaterialGpu mMaterial;

	// For Local Scene
	glm::vec4 mColor;

	DescriptorMask mDescriptorMask;

	RefCountPtr<RHIBuffer> mUboBuffer;



	// For Ray Tracing
	RefCountPtr<VertexBuffer> mVertexBuffer;

	RefCountPtr<IndexBuffer> mIndexBuffer;

	RefCountPtr<RHIBuffer> mTransformBuffer;

	RefCountPtr<RHIBuffer> mMaterialBuffer;
};